<template>
	<Layout :tab-name="5">
		<div class="rwt-team-area rn-section-gap">
		    <div class="container">
				<el-row>
					<el-col :span="9"><div class="grid-content bg-purple">
						<div class="row row--15">
							<div class="col-lg-10 offset-lg-1"
								v-for="(teamMember, index) in teamData"
								:key="index">
								<Team :team-member="teamMember"/>
							</div>
						</div>
					</div></el-col>
					<el-col :span="15"><div class="grid-content bg-purple-light">
						<div class="row">
							<div class="col-lg-10 offset-lg-1" style="margin-top: -50px;">
								<SectionTitle
									subtitle="function frequency"
									title="功能使用频率"
									data-aos="fade-up"
								/>
							</div>
						</div>
						<Progressbar :progress-data="progressOneData"/>
					</div></el-col>
				</el-row>
		    </div>
		</div>
		
		<Separator/>
		
		<div class="rwt-portfolio-area rn-section-gap">
		    <div class="container">
		        <div class="row">
		            <div class="col-lg-12">
		                <SectionTitle
		                    text-align="center"
		                    subtitle="Image History"
		                    title="图片历史记录"
		                    data-aos="fade-up"
		                    data-aos-delay="60"
		                />
		            </div>
		        </div>
		        <Portfolio class="mt--20" ref="portfolio" column="col-lg-3 col-md-6 mt--30"/>
		    </div>
		</div>
	</Layout>
</template>

<script>
	import Layout from '../../components/common/Layout.vue'
	import Team from '../../components/elements/team/Team.vue'
	import SectionTitle from '../../components/elements/sectionTitle/SectionTitle.vue'
	import Separator from '../../components/elements/separator/Separator.vue'
	import Portfolio from '../../components/elements/portfolio/Portfolio.vue'
	import PortfolioItemMixin from '../../mixins/PortfolioItemMixin.js'
	import Progressbar from '../../components/elements/progressbar/Progressbar.vue'
	import Button from '../../components/elements/button/Button.vue'
	export default {
	    name: 'Personal',
	    components: {Layout,Team,SectionTitle,Separator,Portfolio,Progressbar,Button},
	    data() {
	        return {
				teamData:[
					{
						image: '',
						name: '',
						phone: '',
						description: '',
					}
				],
				progressOneData: [
				    {
				        id: 1,
				        title: '目标提取',
				        percentage: 0,
				        progressClass: 'bar-color-1',
				    },
				    {
				        id: 2,
				        title: '变化检测',
				        percentage: 0,
				        progressClass: 'bar-color-2',
				    },
				    {
				        id: 3,
				        title: '目标检测',
				        percentage: 0,
				        progressClass: 'bar-color-3',
				    },
				    {
				        id: 4,
				        title: "地物分类",
				        percentage: 0,
				        progressClass: 'bar-color-4',
				    },
				]
			}
		},
		mounted() {

			if(this.$ls.get('userInfo')!==null){
				this.getPercentage()
				this.getUserInfo()
				// this.$refs.portfolio.portfolioData=this.portfolioItems
			}
		},
		methods:{
			getUserInfo(){
				var that = this;
				/* var token =this.$ls.get('userInfo').token */
				that.$axios.get(this.$global.apiUrl+'user/'+this.$ls.get('userInfo').id,{
					headers:{
						'token':this.$ls.get('userInfo').token
					}
				})
				.then(res=>{
					var userInfo=res.data.data;
					that.teamData[0].image=userInfo.avatar
					that.teamData[0].name=userInfo.name
					that.teamData[0].phone=userInfo.phone
					that.teamData[0].description=userInfo.content || "这家伙很懒，什么都没有留下"
				})
				.catch(function(error) {
					console.log(error);
				});
			},
			getPercentage(){
				var that = this;
				that.$axios.get(this.$global.apiUrl+'record/statistics?userId='+this.$ls.get('userInfo').id)
				.then(res=>{
					// console.log(this.$global.apiUrl+'record/statistics?userId='+this.$ls.get('userInfo').id)
					var percentageArray = res.data.data;
					that.progressOneData[0].percentage = Math.round(100*percentageArray.目标提取)
					that.progressOneData[1].percentage = Math.round(100*percentageArray.变化检测)
					that.progressOneData[2].percentage = Math.round(100*percentageArray.目标检测)
					that.progressOneData[3].percentage = Math.round(100*percentageArray.地物分类)
				})
				.catch(function(error) {
					console.log(error);
				});
			}
		}
	}
	
</script>

<style>
</style>
